package com.ruoyi.fun.service.impl;

import java.util.List;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fun.mapper.EcOrderMapper;
import com.ruoyi.fun.domain.EcOrder;
import com.ruoyi.fun.service.IEcOrderService;

/**
 * 订单Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@Service
public class EcOrderServiceImpl implements IEcOrderService 
{
    @Autowired
    private EcOrderMapper ecOrderMapper;

    /**
     * 查询订单
     * 
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    @DataScope(userAlias = "o", permission = "fun:order:query")
    public EcOrder selectEcOrderByOrderId(Long orderId)
    {
        return ecOrderMapper.selectEcOrderByOrderId(orderId);
    }

    /**
     * 查询订单列表
     * 
     * @param ecOrder 订单
     * @return 订单
     */
    @Override
    @DataScope(userAlias = "o", permission = "fun:order:list")
    public List<EcOrder> selectEcOrderList(EcOrder ecOrder)
    {
        return ecOrderMapper.selectEcOrderList(ecOrder);
    }

    /**
     * 新增订单
     * 
     * @param ecOrder 订单
     * @return 结果
     */
    @Override
    public int insertEcOrder(EcOrder ecOrder)
    {
        ecOrder.setCreateTime(DateUtils.getNowDate());
        // orgId应该由Controller层传入，不在Service层设置默认值
        return ecOrderMapper.insertEcOrder(ecOrder);
    }

    /**
     * 修改订单
     * 
     * @param ecOrder 订单
     * @return 结果
     */
    @Override
    public int updateEcOrder(EcOrder ecOrder)
    {
        ecOrder.setUpdateTime(DateUtils.getNowDate());
        return ecOrderMapper.updateEcOrder(ecOrder);
    }

    /**
     * 批量删除订单
     * 
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteEcOrderByOrderIds(Long[] orderIds)
    {
        return ecOrderMapper.deleteEcOrderByOrderIds(orderIds);
    }

    /**
     * 删除订单信息
     * 
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deleteEcOrderByOrderId(Long orderId)
    {
        return ecOrderMapper.deleteEcOrderByOrderId(orderId);
    }

    /**
     * 根据orderId和组织ID查询Order
     * 
     * @param orderId Order主键
     * @param orgId 组织ID
     * @return Order
     */
    @Override
    public EcOrder selectEcOrderByOrderIdAndOrgId(Long orderId, Long orgId)
    {
        return ecOrderMapper.selectEcOrderByOrderIdAndOrgId(orderId, orgId);
    }

    /**
     * 根据组织ID查询Order列表
     * 
     * @param ecorder Order
     * @param orgId 组织ID
     * @return Order集合
     */
    @Override
    public List<EcOrder> selectEcOrderListByOrgId(EcOrder ecorder, Long orgId)
    {
        return ecOrderMapper.selectEcOrderListByOrgId(ecorder, orgId);
    }
    

}